/*
 *  Copyright (C) 2011 JiangHongTiao <jjurco.sk_gmail.com>
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package sk.lieskove.jianghongtiao.websearch;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.text.Normalizer;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;

/**
 *
 * @author xjuraj
 */
public class Positions {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException {
        int maxLng = 3;
        //no numbers
        Pattern p = Pattern.compile("[0-9]");

        String fileName = "resources/preprocessing/positionNames.txt";
        Scanner scanner = new Scanner(new FileInputStream(fileName), "UTF-8");
        Set<String> positions = new TreeSet<String>();
        try {
            while (scanner.hasNextLine()) {
                String line = Normalizer.normalize(scanner.nextLine().toLowerCase(),
                        Normalizer.Form.NFC);
                //split to words
                String[] split = line.split("\\W");
                for (int i = 0; i < split.length; i++) {
                    String string = split[i];
                    if ((string != null) &&
                        (!string.equals("")) &&
                        (!p.matcher(string).find()) &&
                        (string.length() > maxLng)
                        ) {
                        positions.add(string);
                    }
                }
            }
        } finally {
            scanner.close();
        }
        for (Iterator<String> it = positions.iterator(); it.hasNext();) {
            String string = it.next();
            System.out.println(string);
        }
    }
}
